using System;
using System.IO;

namespace RStein.Posterous.API
{
    public static class StreamExtensions
    {
        public static readonly int BUFFER_SIZE = 1024;
        public static void CopyToStream(this Stream originalStream, Stream targetStream)
        {
            if (originalStream == null)
            {
                throw new ArgumentNullException("originalStream");
                
            }
            if (targetStream == null)
            {
                throw new ArgumentNullException("targetStream");
            }

            byte[] buffer = new byte[BUFFER_SIZE];
            int read = 0;
            while((read = originalStream.Read(buffer, 0, BUFFER_SIZE)) > 0)
            {
                targetStream.Write(buffer, 0, read);
            }
        }
    }
}